<?php

namespace app\admin\model\report;

use think\Model;
use traits\model\SoftDelete;

class Finance extends Model
{

    use SoftDelete;


    // 表名
    protected $name = 'finance';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'status_text'
    ];


    public const STATUS_SH = 100; //销售单
    public const STATUS_SHTH = 200; //销售退货单
    public const STATUS_LS = 300; //零售单
    public const STATUS_JH = 400; //进货单
    public const STATUS_JHTH = 500; //进货退货单
    public const STATUS_SK = 600; //收款单
    public const STATUS_FK = 700; //付款单
    public const STATUS_SR = 800; //项目收入单
    public const STATUS_ZC = 900; //项目支出单
    public const STATUS_TZC = 1000; //转账单
    public const STATUS_DBD_C = 1100; //调拨单(出)
    public const STATUS_DBD_R = 1200; //调拨单(入)
    public const STATUS_DBD = 1300; //调拨单
    public const STATUS_QTR = 1400; //其他入库单
    public const STATUS_QTC = 1500; //其他出库单
    public const STATUS_SYSTEM_DEL = 9800; //系统删除
    public const STATUS_SYSTEM = 9900; //系统修改
    public const STATUS_SYSTEM_DEL_XSD = 10000; //系统删除销售单
    public const STATUS_SYSTEM_DEL_XSTHD = 20000; //系统删除销售退货单
    public const STATUS_SYSTEM_DEL_JHD = 40000; //系统删除进货单
    public const STATUS_SYSTEM_DEL_THD = 50000; //系统删除退货单
    public const STATUS_SYSTEM_DEL_QTRKD = 14000; //系统删除其他入库单
    public const STATUS_SYSTEM_DEL_QTCKD = 15000; //系统删除其他出库单


    public const STATUS_ARR = [
        self::STATUS_SH => '销售单',
        self::STATUS_SHTH => '销售退货单',
        self::STATUS_LS => '零售单',
        self::STATUS_JH => '进货单',
        self::STATUS_JHTH => '进货退货单',
        self::STATUS_SK => '收款单',
        self::STATUS_FK => '付款单',
        self::STATUS_SR => '项目收入单',
        self::STATUS_ZC => '项目支出单',
        self::STATUS_TZC => '转账单',
        self::STATUS_DBD_C => '调拨单(出)',
        self::STATUS_DBD_R => '调拨单(入)',
        self::STATUS_DBD => '调拨单',
        self::STATUS_QTR => '其他入库单',
        self::STATUS_QTC => '其他出库单',
        self::STATUS_SYSTEM_DEL => '系统删除',
        self::STATUS_SYSTEM => '系统修改',
        self::STATUS_SYSTEM_DEL_XSD => '系统删除销售单',
        self::STATUS_SYSTEM_DEL_XSTHD => '系统删除销售退货单',
        self::STATUS_SYSTEM_DEL_JHD => '系统删除进货单',
        self::STATUS_SYSTEM_DEL_THD => '系统删除退货单',
        self::STATUS_SYSTEM_DEL_QTRKD => '系统删除其他入库单',
        self::STATUS_SYSTEM_DEL_QTCKD => '系统删除其他出库单',

    ];


    public function getStatusList()
    {
        return [
            self::STATUS_SH => '销售单',
            self::STATUS_SHTH => '销售退货单',
         //   self::STATUS_LS => '零售单',
            self::STATUS_JH => '进货单',
            self::STATUS_JHTH => '进货退货单',
            self::STATUS_SK => '收款单',
            self::STATUS_FK => '付款单',
            self::STATUS_SR => '项目收入单',
            self::STATUS_ZC => '项目支出单',
            self::STATUS_TZC => '转账单',
//            self::STATUS_DBD_C => '调拨单(出)',
//            self::STATUS_DBD_R => '调拨单(入)',
            self::STATUS_DBD => '调拨单',
            self::STATUS_QTR => '其他入库单',
            self::STATUS_QTC => '其他出库单',

        ];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


}
